// pages/jielong/hexiao/hexiao.js
var app = getApp()
var commonURL = app.data.baseURL;
var commonURLYY = app.data.newURL;
const commonURLXX = app.data.XCX_PAY;
const util = require("../../../util/util.js");
var commonURLWW = app.data.testURL;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    onclose_cover: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    console.log(options)
    if (options.isTz == '1') {
      this.setData({
        isTz: true
      })

    } else {
      this.setData({
        isTz: false
      })

    }
  },
  // 团长二维码
  getCode: function (e) {
    console.log(e)
    var that = this;
    that.setData({
      onclose_cover: true
    })
    wx.request({                   //获取二维码
      url: commonURLWW + 'op=qrcode',
      data: {
        openid: app.data.openid,
        unionId: app.data.unionId || wx.getStorageSync('unionId'),
        state: 1
      },
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res)
        that.setData({
          code_img: res.data.url
        })
        wx.setStorage({
          key: "code_img",
          data: res.data
        })
      }
    })
  },
  //扫一扫
  verify: function (e) {
    console.log(e)
    var orderno = e.currentTarget.dataset.id;
    var areaid = e.currentTarget.dataset.areaid;
    wx.scanCode({
      onlyFromCamera: true,
      success(res) {
        console.log(res)
        wx.request({
          url: commonURL + 'op=scan',
          data: {
            openid: app.data.openid,
            uniacid: app.data.GZHid,
            unionId: app.data.unionId || wx.getStorageSync('unionId'),
            tuan_openid: util.parseURL(res.result).mid
          },
          success: function (res) {
            if (res.data.status == 1) {
              wx.navigateTo({
                url: '../check/check?=tuan_openid' + util.parseURL(res.result).mid,
              })
            } else {
              wx.showToast({
                title: '暂无核销权限',
              })
            }
          }
        })
      }
    })
  },
  close_cover: function () {
    this.setData({
      onclose_cover: false
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})